#!/bin/bash
# -------------------------------------------------------------------------
# This script is licensed under GNU GPL version 2.0 or above
# -------------------------------------------------------------------------
echo "$0 - BEGIN" 

# Store file name
FILE=$HOME/.mnts
 
# make sure file exist and readable
if [ ! -f $FILE ]; then
   echo "$FILE : does not exist"
   exit 1
elif [ ! -r $FILE ]; then
   echo "$FILE: can not read"
   exit 2
fi

# read $FILE using the file descriptors
# Set loop separator to end of line
BAKIFS=$IFS
IFS=$(echo -en "\n\b")
exec 3<&0
exec 0<$FILE
while read line
do
	# Mount the share read from the .mounts file
	/usr/bin/smbh-mount $line
done
exec 0<&3
 
# restore $IFS which was used to determine what the field separators are
IFS=$BAKIFS

echo "$0 - END"
exit 0
